package com.qdlc.p2p.dal.model;

import java.math.BigDecimal;

import org.springframework.beans.BeanUtils;

import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.common.SystemConfigHelper;
import com.qdlc.p2p.dal.common.SystemConfigHelper.Nid;
import com.qdlc.p2p.dal.dto.AccountLogHis;
import com.qdlc.p2p.dal.util.SystemConfigs;

/**
 * 资金记录Model
 * 
 * @author xx
 * @version 2.0
 * @since 2014年3月27日
 */
public class AccountLogHisModel extends AccountLogHis {

	/** 当前页面 */
	private int page;
	/** 资金记录类型名称 */
	private String typeName;
	/** 交易方 */
	private String toUserName;
	/** 开始日期 **/
	private String startTime;
	/** 结束日期 **/
	private String endTime;
	/**日期范围：0：全部，1：最近七天 2：最近一个月  3：最近两个月，4 最近三个月**/
	private int time;
	/** 用户名 */
	private String userName;
	/** 标名称 */
	private String borrowName;
	/**
	 * 资金类型--取该名字为了前端统一
	 */
	private String status;
	
	/** 条件查询 */
	private String searchName;

	public static AccountLogHisModel instance(AccountLogHis accountLogHis) {
		AccountLogHisModel accountLogHisModel = new AccountLogHisModel();
		BeanUtils.copyProperties(accountLogHis, accountLogHisModel);
		return accountLogHisModel;
	}

	public AccountLogHis prototype() {
		AccountLogHis accountLogHis = new AccountLogHis();
		BeanUtils.copyProperties(this, accountLogHis);
		return accountLogHis;
	}

	/**
	 * 获取（隐藏一定位数的）交易对方
	 * 
	 * @return
	 */
	public String getHideToUserName() {
		Long adminId = SystemConfigHelper.getLongValue(Nid.ADMIN_ACCOUNT);
		String adminName = SystemConfigs.WEB_NAME;
		if (getToUser()==null || getToUser().getUserId() == adminId) {
			return adminName;
		}
	    if (StringUtil.isBlank(toUserName) || toUserName.length()==1) {
	    	return adminName;
	    }
		return StringUtil.hideStr(toUserName, 1, toUserName.length()-1);
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getToUserName() {
		return toUserName;
	}

	public void setToUserName(String toUserName) {
		this.toUserName = toUserName;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getBorrowName() {
		return borrowName;
	}

	public void setBorrowName(String borrowName) {
		this.borrowName = borrowName;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public String getSearchName() {
		return searchName;
	}

	public void setSearchName(String searchName) {
		this.searchName = searchName;
	}
	/**
     * 账户总额转换为字符串防止数值过大变成科学计数法显示
     * @return
     */
    public String getTotalString() {
    	return new BigDecimal(Double.toString(getTotal())).toPlainString();
    }
    /**
     * 操作金额转换为字符串防止数值过大变成科学计数法显示
     * @return
     */
    public String getMoneyString() {
    	return new BigDecimal(Double.toString(getMoney())).toPlainString();
    }
    /**
     * 可用金额转换为字符串防止数值过大变成科学计数法显示
     * @return
     */
    public String getUseMoneyString() {
    	return new BigDecimal(Double.toString(getUseMoney())).toPlainString();
    }
    /**
     * 冻结金额转换为字符串防止数值过大变成科学计数法显示
     * @return
     */
    
    public String getNoUseMoneyString() {
    	return new BigDecimal(Double.toString(getNoUseMoney())).toPlainString();
    }
    /**
     * 待收金额转换为字符串防止数值过大变成科学计数法显示
     * @return
     */
    public String getCollectionString() {
    	return new BigDecimal(Double.toString(getCollection())).toPlainString();
    }
}
